package com.example.framework.mqtt.listener;

import cn.hutool.json.JSONUtil;
import com.example.framework.mqtt.core.annotation.MqttMessageListener;
import net.dreamlu.iot.mqtt.codec.MqttPublishMessage;
import net.dreamlu.iot.mqtt.core.client.IMqttClientMessageListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tio.core.ChannelContext;

/**
 * <p>
 *
 * </p>
 *
 * @author sfjiang
 * @since 2024/11/26 19:24
 */
@MqttMessageListener(topics = {"example/properties/set"})
public class PropertiesSetListener implements IMqttClientMessageListener {

    private static final Logger log = LoggerFactory.getLogger(PropertiesSetListener.class);

    @Override
    public void onMessage(ChannelContext context, String topic, MqttPublishMessage message, byte[] payload) {
        log.info("{} message arrived: {}, byte[]={}", topic, JSONUtil.toJsonStr(message), payload);
    }
}
